package com.ruoyi.web.controller.miniapp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.miniapp.domain.MiniGroupInfo;
import com.ruoyi.miniapp.service.IMiniGroupInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 团队信息Controller
 * 
 * @author duantao
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/miniapp/groupInfo")
public class MiniGroupInfoController extends BaseController
{
    @Autowired
    private IMiniGroupInfoService miniGroupInfoService;

    /**
     * 查询团队信息列表
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiniGroupInfo miniGroupInfo)
    {
        startPage();
        List<MiniGroupInfo> list = miniGroupInfoService.selectMiniGroupInfoList(miniGroupInfo);
        return getDataTable(list);
    }

    /**
     * 导出团队信息列表
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:export')")
    @Log(title = "团队信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiniGroupInfo miniGroupInfo)
    {
        List<MiniGroupInfo> list = miniGroupInfoService.selectMiniGroupInfoList(miniGroupInfo);
        ExcelUtil<MiniGroupInfo> util = new ExcelUtil<MiniGroupInfo>(MiniGroupInfo.class);
        util.exportExcel(response, list, "团队信息数据");
    }

    /**
     * 获取团队信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(miniGroupInfoService.selectMiniGroupInfoByGroupId(groupId));
    }

    /**
     * 新增团队信息
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:add')")
    @Log(title = "团队信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiniGroupInfo miniGroupInfo)
    {
        return toAjax(miniGroupInfoService.insertMiniGroupInfo(miniGroupInfo));
    }

    /**
     * 修改团队信息
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:edit')")
    @Log(title = "团队信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiniGroupInfo miniGroupInfo)
    {
        return toAjax(miniGroupInfoService.updateMiniGroupInfo(miniGroupInfo));
    }

    /**
     * 删除团队信息
     */
    @PreAuthorize("@ss.hasPermi('miniapp:groupInfo:remove')")
    @Log(title = "团队信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(miniGroupInfoService.deleteMiniGroupInfoByGroupIds(groupIds));
    }
}
